package org.wdcode.web.ftp.client;

import org.wdcode.core.factory.BaseFactory;
import org.wdcode.web.ftp.client.FTPClient;
import org.wdcode.web.params.WdWebParams;

/**
 * FTP工厂
 * @author WD
 * @since JDK6
 * @version 1.0 2010-04-20
 */
public final class FTPClientFactory extends BaseFactory<FTPClient> {
	// 工厂
	private final static FTPClientFactory	FACTORY;

	/**
	 * 静态初始化
	 */
	static {
		FACTORY = new FTPClientFactory();
	}

	/**
	 * 返回工厂
	 * @return 工厂
	 */
	public final static FTPClientFactory getFactory() {
		return FACTORY;
	}

	/**
	 * 新生成一个FTPClient
	 * @return FTPClient
	 */
	@Override
	public final FTPClient newInstance() {
		return newInstance(WdWebParams.getFtpHost(), WdWebParams.getFtpPort(), WdWebParams.getFtpUser(), WdWebParams.getFtpPassword());
	}

	/**
	 * 新生成一个FTPClient
	 * @param host 主机
	 * @param port 端口
	 * @param user 用户
	 * @param password 密码
	 * @return FTPClient
	 */
	public final FTPClient newInstance(String host, int port, String user, String password) {
		return new FTPClientApache(host, port, user, password);
	}
}
